<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>库存期初建账管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
		
			$("#check_ok").click(function(){
				//获取所有的选择列
				
				var data=[];
				$("#contentTable").find(":checkbox:checked").each(function(key,value){
					
				 	var tr = $(this).parent().parent().parent();
					data.push(tr);
					
				});
				if(data.length==0){
					layer.msg("至少选择一条记录",{"icon":7, "time":1000});
					return ;
				}
				parent.layer.closeAll();
				parent.layerDiv(data);
			});
			
		});
		 function reset(){
				$("#searchForm").reset();
				var selectVal = $("form:select");
				for(var i=0;i<selectVal.lengeth;i++){
					selectVal[i].options[0].selected= true;
				}
		} 
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
// 		function change(){
			
// 			var url = "${ctx}/vaccinate/bsProduct/findbatchByVacc";
// 			$.ajax({
// 				url:url,
// 				data:{"vaccId":$("#vaccineid").val()},
// 				success:function(data){
					
// 					var html = "";
// 					var htmll =""
// 					$.each(data,function(i,t){
// 						html += "<option>" + t.batchno + "</option>"
						
// 					});
					
					
// 					 var companyNameT = "_";
// 					$.each(data,function(i,t){
// 						if(companyNameT.indexOf(t.companyName) < 0){
// 							htmll += "<option>" + t.companyName + "</option>"
// 							companyNameT += t.companyName + "_";
// 						}
						
// 					}); 
// 					$("#batchno").html("<option value=''>--请选择--</option>");
// 					$("#companyName").html("<option value=''>--请选择--</option>");
// 					$("#companyName").html(htmll);
// 					$("#batchno").html(html);
					
// 				}
				
// 			});
// 		}
		
		var bsProduct = JSON.parse('${fns:toJson(bsProduct)}');
		function finishVaccine2Company(){
			if(bsProduct && bsProduct["vaccineId"]){
			   $("#vaccineId").val(bsProduct.vaccineId);
			   $("#vaccineId").select2();
			   $("#vaccineId").change();
			}
		}
		function finishSelectCompany(){
			$("#companyCode").val(bsProduct.companyCode);
			$("#companyCode").select2();
		}
		
	</script>

	<style type="text/css">
		body{
			padding:10px;
		}
		.minWidth {
			min-width: 177px;
		}	
	</style>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/vaccinate/bsProduct/">库存列表</a></li>
	</ul>
	<form:form id="searchForm" modelAttribute="bsProduct" action="${ctx}/vaccinate/bsProduct/getList" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<div class="breadcrumb">
			<table class="table table-bordered">
				<tr>
					<th>疫苗名称:</th>
					<td>
						<form:select path="vaccineId" id="vaccineId" class="span2 minWidth vaccine2Company" >
							<form:option value=""  label="--请选择--"/>
						</form:select>
					</td>
					<th>生产企业：</th>
					<td>
						<form:select path="companyCode" id="companyCode" class="span2 minWidth selectCompany">
							<form:option value="" label="--请选择--"/> 
						</form:select>
					</td>
					<th>疫苗批号：</th>
					<td>
<%-- 						<form:select path="bsVaccineBatchno.batchno" id="batchno" class="span2 minWidth"> --%>
<%-- 						<form:option value="" label="--请选择--"/>  --%>
<%-- 						</form:select> --%>
							<input type="text" name="batchno" class="input-medium"/>
					</td>
				</tr>
				<tr>
					<th>起始有效期：</th>
					<td>
						<input name="beginVaccExpDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
							value="<fmt:formatDate value="${bsProduct.beginVaccExpDate}" pattern="yyyy-MM-dd"/>"
							onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
							
					</td>
					<th>截止有效期：</th>
					<td colspan="3">
						<input name="endVaccExpDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
							value="<fmt:formatDate value="${bsProduct.endVaccExpDate}" pattern="yyyy-MM-dd"/>"
							onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
					</td>
				</tr>
			</table>
		</div>
		
		<ul class="ul-form breadcrumb">
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="btns"><input onclick="reset()"  class="btn btn-primary" type="button" value="重置"/></li>
			<li class="btns"><input id="check_ok" class="btn btn-primary"  type="button"  value="确认选择"/></li>
			<li class="clearfix"></li>
		</ul>
		
	</form:form>
	
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>选择</th>
				<th>疫苗名称</th>
				<th>疫苗属性</th>
				<th>疫苗生产企业</th>
				<th>批号</th>
				<th>规格(剂/支或粒)</th>
				<th>剂量</th>
				<th>有效期</th>
				<th>库存数量(支或粒)</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="bsProduct">
			<tr>
				<td>
					<input type="checkbox">
				</td>
				<td>
					${bsProduct.bsVaccineBatchno.vaccineName}<input type="hidden" name="p_id" value="${bsProduct.id}">
				</td>
				<td>
					${fns:getDictLabel(bsProduct.bsVaccineBatchno.type, "bs_vaccineInfo_type", "")}
				</td>
				<td>
					${bsProduct.bsVaccineBatchno.companyName}
				</td>
				<td>
					${bsProduct.bsVaccineBatchno.batchno}
				</td>
				<td>
					${bsProduct.bsVaccineBatchno.spec}
				</td>
				<td>
					${bsProduct.bsVaccineBatchno.dose}
				</td>
				<td>
					<fmt:formatDate value="${bsProduct.bsVaccineBatchno.outBoundDate}" pattern="yyyy-MM-dd"/>
				</td>
				<td>
					${bsProduct.storenum}
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>